﻿﻿/*  
 * 测试脚本 
 */ 
var mapId = 321116000; 
 
function init() { 
    em.setProperty("state", "0"); 
    em.setProperty("leader", "true"); 
} 
 
function setup(level, leaderid) { 
    em.setProperty("state", "1"); 
    em.setProperty("leader", "true"); 
    var eim = em.newInstance("Wulusi"); 
 
    var map = eim.setInstanceMap(970072300); 
    map.resetFully(); 
    map.killAllMonsters(true); 
    var mob = em.getMonster(8881000); 

    mob.changeLevel(200); 
    mob.getChangedStats().setOHp(160000000000);
    mob.setHp(160000000000);
    eim.registerMonster(mob); 
    map.spawnMonsterOnGroundBelow(mob, new java.awt.Point(1392,86)); //刷出这个怪物 
    eim.startEventTimer(1000 * 60 * 60); //60 min 
    return eim; 
} 
 
function playerEntry(eim, player) { 
    var map = eim.getMapInstance(0); 
    player.changeMap(map, map.getPortal(0)); 
} 
 
function playerRevive(eim, player) { 
    return false; 
} 
 
function changedMap(eim, player, mapid) { 
    if (mapid != 970072300 ) { 
        eim.unregisterPlayer(player); 
        if (eim.disposeIfPlayerBelow(0, 0)) { 
            em.setProperty("state", "0"); 
            em.setProperty("leader", "true"); 
        } 
    } 
} 
 
function playerDisconnected(eim, player) { 
    eim.disposeIfPlayerBelow(100, 970072200); 
    em.setProperty("state", "0"); 
    em.setProperty("leader", "true"); 
    return 0; 
} 
 
function monsterValue(eim, mobId) { 
    return 1; 
} 
 
function playerExit(eim, player) { 
    eim.unregisterPlayer(player); 
    if (eim.disposeIfPlayerBelow(0, 0)) { 
        em.setProperty("state", "0"); 
        em.setProperty("leader", "true"); 
    } 
} 
function scheduledTimeout(eim) { 
    eim.disposeIfPlayerBelow(100, 970072200); 
    em.setProperty("state", "0"); 
    em.setProperty("leader", "true"); 
} 
 
function clearPQ(eim) { 
    scheduledTimeout(eim); 
} 
 
function allMonstersDead(eim) { 
  eim.schedule("end", 1000 * 0); 
} 





function end(eim, player){ 
var tz =5;
var ss =Math.floor((3600000-eim.getTimeLeft())/1000)%60;
var mm =Math.floor((3600000-eim.getTimeLeft())/1000/60);
var ee = Math.floor((3600000-eim.getTimeLeft())/1000);
if (ee <= 120){
tz = 0;}
if (ee >= 121 && ee<= 300){
tz = 1;}
if (ee >= 301 && ee<= 480){
tz = 2;}
if (ee >= 481 && ee<= 600){
tz = 3;}
if (ee >= 601 && ee<= 720){
tz = 4;}
if (ee >= 721 ){
tz = 5;}
            for (var i = 0; i < eim.getPlayerCount(); i++) {
                eim.getPlayers().get(i).openNpc(9070100, tz);//掉落結算NPC
            }


    var map = eim.setInstanceMap(mapId); 

    em.broadcastYellowMsg("[烏魯斯] - 已被"+ eim.getPlayers().get(0).getName()+"帶領的團隊打敗了！花費了"+mm+"分"+ ss +"秒"); 
  em.broadcastServerMsg(5120027, "烏魯斯已被消灭，將在10秒後傳送出去。" ,true); 
    eim.startEventTimer(1000 * 10); //10 min 
   // map.spawnNpc(2400006, new java.awt.Point(-16, 392)); 
   
} 
 
function leftParty(eim, player) {} 
function disbandParty(eim) {} 
function playerDead(eim, player) {} 
function cancelSchedule() {}function pickUpItem(eim, player, itemID) {}